TARGET		= main

#
# Tools used
#
CC		= gcc
CXX		= g++
FLEX		= flex
BISON		= bison
DIFF		= diff

#
# Assemble sources, objects, and headers
#
C_SRCS	       := $(wildcard *.c)
C_OBJS	       := $(C_SRCS:.c=.o)

CXX_SRCS       := $(wildcard *.cc)
CXX_OBJS       := $(CXX_SRCS:.cc=.o)

#HDRS    = $("../")
HDRS	        += $(wildcard *.h)

INCLUDES	=
LIBS		= -lm

#
# Choose suitable commandline flags 
#
ifeq "$(MAKECMDGOALS)" "opt"
CFLAGS   = -O2
CXXFLAGS = -O2
else
CFLAGS   = -g -Wno-unused-parameter -O2 #-pedantic
CXXFLAGS = -g -O2 #-pedantic
endif

.PHONY:	clean test trace_select opt

trace_select opt: $(TARGET)

$(TARGET):  $(C_OBJS) $(CXX_OBJS)
	$(CXX) -o $(TARGET) $(C_OBJS) $(CXX_OBJS) $(LIBS)

%.o:%.c
	$(CC) -c $(CFLAGS) $<

%.o:%.cc
	$(CXX) -c $(CXXFLAGS) $<

$(C_OBJS) $(CXX_OBJS): $(HDRS)

test:	$(TARGET) 
	@for file in ../Benchmarks2/*.bench; \
	do \
          f=`basename $$file`; \
     echo "$$f started"; \
	  ./$(TARGET) $$file 32 > ../results/res32_$$f; \
	  echo "$$f passed"; \
	done
	
clean : 
	rm -f *.o $(TARGET) Check* trace*

